package org.jw.wishlist.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.jw.wishlist.entity.source.ItemSource;
import org.jw.wishlist.service.ItemSourceResolvingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Jiawei Zhao
 */
@RestController
@RequestMapping("/resolving")
@Tag(name = "解析项目")
public class ItemSourceResolvingController {

  private final ItemSourceResolvingService service;

  @Autowired
  public ItemSourceResolvingController(ItemSourceResolvingService service) {
    this.service = service;
  }

  @GetMapping
  @Operation(description = "解析口令")
  public ResponseEntity<ItemSource> resolveLinkCode(@RequestParam("linkCode") String linkCode) {
    return ResponseEntity.ok(service.resolve(linkCode));
  }

}
